<?php
// 游客类
class Tourist extends User_V2_Member
{
    public function __construct ($uid = NULL, $userinfo = NULL)
    {
        $this->_uid = $uid;
        $this->_userinfo = NULL;

        parent::__construct ($uid, $userinfo);
    }

    public function getRealName ()
    {
        $userinfo = $this->getUserInfo();
        return Arr::get($userinfo, 'realName');
    }

    public function getUserInfo ()
    {
        $baseInfo = parent::getUserInfo();
        $userInfo = Util_User::getUserInfo($this->_uid);
        $info  = $this->loadUserInfo();

        $baseInfo['active'] = Arr::get($info,'active');;
        $baseInfo['email'] =  Arr::get($info,'email');
        $baseInfo['utype'] =  Arr::get($info,'utype');
        $baseInfo['realName'] =  Arr::get($userInfo,'userFamily').Arr::get($userInfo,'userName');
        $baseInfo['userAge'] = Arr::get($userInfo,'userAge');
        $baseInfo['userGender'] =  Arr::get($userInfo,'userGender');
        $baseInfo['userPhone'] = Arr::get($userInfo,'userPhone');

        return $baseInfo;
    }

    public function loadUserInfo ()
    {
        $query = DB::select()
            ->from('user_v2')
            ->where('uid', '=', (int) $this->_uid)
            ->execute();

        if ($query->count() > 0)
        {
            $current = $query->current();
            $uid     = $current['uid'];
            $status  = $current['status'];
            if ($status != 1)
                $this->_userinfo = array();
            else
                $this->_userinfo = $current;
        }
        else
        {
            $this->_userinfo = array();
        }
        return $this->_userinfo;
    }

}


